package com.ilearn.rest.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;

/**
 *
 *@project chinabond-edb
 *@description 异步处理配置类
 *
 *@errorcode
 *          SystemException</br>
 *
 *@author
 *       2018-08-10 13:50 huzy Create 1.0 <br>
 *
 *@copyright ©2017-2017 中央结算公司，版权所有。
 */
@Configuration
@EnableAsync
public class AsyncConfiguration
{

    @Bean(name = "asyncExecutor")
    public Executor asyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(1);
        executor.setMaxPoolSize(1);
        executor.setQueueCapacity(100);
        executor.setThreadNamePrefix("Task-AsyncThread-");
        executor.initialize();
        return executor;
    }
}